package day17;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

//重复的自定义元素不加入HASHMAP
//关键点：在JavaBeen里重写HashCode and equals方法！！！

public class Map03_W {
    public static void main(String[] args) {
        Map<Student,String> map = new HashMap<>();
        Student s1= new Student ("xiaoming", 18);
        Student s2= new Student ("xiaogang", 19);
        Student s3= new Student ("xiaoming", 18);
        map.put(s1,"beijing");
        map.put(s2,"shanghai");
        map.put(s3,"suzhou");

        Set<Student> set = map.keySet();
        for (Student student : set) {
            String name = student.getName();
            int age = student.getAge();
            String value=map.get(student);
            System.out.println(name+"\t"+age+"\t"+value);
        }
    }

}
